import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";

var _dec, _class;

/**
 * 可拖动的 新增的字段
 */
import React from 'react';
import { DragSource } from 'react-dnd';
import { DragType } from "../config";
import { getIconClassName } from "../icon";
var classNames = {
  formClassName: getIconClassName('form'),
  tableClassName: getIconClassName('table'),
  toolbarClassName: getIconClassName('buttonq'),
  modalClassName: getIconClassName('square'),
  selectClassName: getIconClassName('select'),
  dateClassName: getIconClassName('date'),
  numberClassName: getIconClassName('plus-numberfill'),
  lovClassName: getIconClassName('search'),
  inputClassName: getIconClassName('wenben'),
  checkboxClassName: getIconClassName('checkbox'),
  switchClassName: getIconClassName('kaiguanclose'),
  buttonClassName: getIconClassName('button-component')
};
var dragFieldSpec = {
  beginDrag: function beginDrag(props) {
    return {
      component: props.component
    };
  }
};

var dragFieldCollect = function dragFieldCollect(connect, monitor) {
  var connectDragSource = connect.dragSource();
  var connectDragPreview = connect.dragPreview();
  var isDragging = monitor.isDragging();
  return {
    connectDragSource: connectDragSource,
    connectDragPreview: connectDragPreview,
    isDragging: isDragging
  };
};

var DragField = (_dec = DragSource(DragType.dragField, dragFieldSpec, dragFieldCollect), _dec(_class = /*#__PURE__*/function (_React$Component) {
  _inherits(DragField, _React$Component);

  var _super = _createSuper(DragField);

  function DragField(props) {
    var _this;

    _classCallCheck(this, DragField);

    _this = _super.call(this, props);
    _this.state = {};
    return _this;
  }

  _createClass(DragField, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          _this$props$component = _this$props.component,
          component = _this$props$component === void 0 ? {} : _this$props$component,
          connectDragSource = _this$props.connectDragSource;
      return connectDragSource && connectDragSource( /*#__PURE__*/React.createElement("div", {
        className: "drag-field pick-box-panel-item"
      }, /*#__PURE__*/React.createElement("i", {
        className: classNames[component.className]
      }), /*#__PURE__*/React.createElement("h3", null, component.name)));
    }
  }]);

  return DragField;
}(React.Component)) || _class);
export default DragField;